package com.util;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.*;

/**
 * 
 * <p>��������:��ȡXML</p>
 * @author  <a href="mailto: zhuyouyoulong</a>
 * @create_date 2008-10-31
 * @version $ Revision: 1.0
 */
public class LoadXML {
	private static final String XML_CONFIG="Config.xml";
	static{
        initXML();
    }
	
	public static void initXML(){
		try{
//�������
        DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
        DocumentBuilder builder=factory.newDocumentBuilder();
        boolean bln=false;
        ClassLoader cl=LoadXML.class.getClassLoader();
        java.io.InputStream in;
        if (cl != null) {
            in = cl.getResourceAsStream(XML_CONFIG);
        } else {
            in = ClassLoader.getSystemResourceAsStream(XML_CONFIG);
        }
        if (in == null) {
            throw new Exception("Configuration file '" + XML_CONFIG + "' not found");
        }
        Document doc = builder.parse(in);
         //����itsite   list(map(name,list(SiteCategoryCond)))
         NodeList nlitsite=doc.getElementsByTagName("itsite");
         //����html����� list(map(name,ParseHtmlCondition))
         NodeList nl = doc.getElementsByTagName("parsehtmlcondition");
         
         for (int i=0;i<nl.getLength();i++){
        	 Element el=(Element)nl.item(i);
        	 
        	 
         }
		}
		catch(Exception e){
			System.out.println("error:"+e.toString());
		}
	}
	
//	ͨ��element�õ�����
    public static String getAttribute(Element el,String name){
        try {
            String rs=el.getAttribute(name);
            return rs.trim();
        } catch (Exception e) {
            // TODOԶ���� catch ��
            return "";
        }
    }
}
